package com.yzw.course.controller;

import com.yzw.common.dto.R;
import com.yzw.common.vo.SubjectVo;
import com.yzw.course.service.EduSubjectService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author Yzw
 * @Description TODO
 * @Date 2023/5/8 11:42
 * @Version 1.0
 */
@RestController
@RequestMapping("/subject")
public class EduSubjectController {
    @Resource
    EduSubjectService eduSubjectService;

    @ApiOperation(value = "导入课程分类Excel")
    @PostMapping()
    public R importExcel(MultipartFile file){
        eduSubjectService.importExcel(file);
        return R.success("导入课程分类成功",null);
    }

    @ApiOperation(value = "树形显示课程分类列表")
    @GetMapping()
    public R getAllSubject(){
        List<SubjectVo> subjects = eduSubjectService.getAllSubject();
        return R.success("查询课程分类列表",subjects);
    }

}
